class Observer {
	//
	static target() {

	}
	constructor(data) {
		this.walk(data)
	}

	walk(data) {
		if (!data || typeof data !== 'object') return

		Object.keys(data).forEach((key) => {
			let val = data[key]
			this.defineReactvie(data, key, val)
		})
	}

	defineReactvie(data, key, val) {
		let that = this
		let dep = new Dep()
		that.walk(val)
		Object.defineProperty(data, key, {
			enumerable: true,
			configurable: true,
			get() {
				//收集依赖次数据的对象
				Dep.target & dep.addSub(Dep.target)
				return val
			},

			set(newValue) {
				if (data[key] === newValue) return
				val = newValue
				that.walk(newValue)
				dep.notify() //发布者发布更新
			}
		})
	}
}